//StatusBar Component Constructor
function StatusBar(e) {
	
	var self = Ti.UI.createView({
		height: e.containerheight,
		width: e.containerwidth	
	});
	
	var connectButton = Ti.UI.createButton({
		title:'Connect',
		height: self.height*0.9,
		width: self.width*0.07,
		center: { x: e.width*0.04 , y: self.height*0.5} ,	
	});
	
	connectButton.addEventListener('click', function(e){
		Ti.App.fireEvent('connect');
	});
	
	self.add(connectButton);
	
	var statusLabel = Ti.UI.createLabel({
		color: '#ffffff',
  		text: 'Not Connected',
  		textAlign: Ti.UI.TEXT_ALIGNMENT_LEFT,
  		left: connectButton.right,	
  		width: 'auto', 
  		height: self.height*0.9	
	});
	
	Ti.App.addEventListener('heartbeat', function(evt) {
		statusLabel.text = 'HEARTBEAT';
		statusLabel.color = '#42ff00';
	});
	
	Ti.App.addEventListener('noheartbeat', function(evt) {
		statusLabel.text = 'CONNECTION LOST';
		statusLabel.color = '#ff0000';
	});
	
	self.add(statusLabel);
	
	return self;
}

//make constructor function the public component interface
module.exports = StatusBar;

